Repository navigation
fix(linux): make Flutter web pages take the Chromium path under WebKitGTK - #1212
Open
KaputterKerl wants to merge 1 commit into
Open
KaputterKerl wants to merge 1 commit into
KaputterKerl wants to merge 1 commit into
Conversation
…tGTK
Flutter web chooses its browser-specific code path from navigator.vendor.
Under WebKitGTK it takes the WebKit path, where checkbox state is presented
one frame late: the checkbox that was clicked last only updates on the next
pointer event. On the login page ("Remember me", "I have read and agree") and
in Print Preprocessing (Time-lapse, Auto Leveling, Extrusion flow calibration)
checkmarks seem to disappear on hover or to affect each other.
Reproduced with plain WebKitGTK 2.54.1 and 2.50.6 and the standalone Snapmaker
Control pages; the same pages are fine in a desktop browser. The Windows build
already sends a Chromium user agent and therefore takes the Blink path. A
Chromium-style user agent alone is not enough on Linux, navigator.vendor has to
be changed as well, so add a user script (scoped to /web/flutter_web/ pages)
that reports a Chromium vendor and user agent.
Measured with synthetic pointer input: 8 checkpoints of clicking and hovering
both login checkboxes, 5 wrong without the script, 0 wrong with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix checkboxes in the bundled Flutter web pages (login, Print Preprocessing) that show a stale state under WebKitGTK on Linux.
Symptom: On the login page ("Remember me", "I have read and agree") and in Print Preprocessing ("Time-lapse camera", "Auto leveling", "Extrusion flow calibration"), the checkbox that was clicked last does not update until the next pointer event. Checkmarks seem to disappear when the pointer moves to another element, or the two checkboxes seem to affect each other.
Cause: Flutter web chooses its browser-specific code path from
navigator.vendor(seeK()influtter_bootstrap.js). WebKitGTK reportsApple Computer, Inc., so Flutter takes its WebKit path, where the new checkbox state is presented one frame late. The same pages are fine in a desktop browser and on Windows, where the slicer already sends a Chromium user agent (... Chrome/107 ... Edg/107) and Flutter takes the Blink path.A Chromium-style user agent alone is not enough on Linux (tested with
Edg/in the UA, still 5 of 8 checkpoints wrong);navigator.vendorhas to be changed as well, and WebKitGTK has no setting for that.Change:
WebView::AddFlutterCompatScript()adds a user script on Linux that reportsnavigator.vendor = "Google Inc."and a Chromium user agent. The script returns immediately unless the page URL contains/web/flutter_web/, so other pages are unaffected. On other platforms the function does nothing.PrinterWebView::SendAPIKey()right afterRemoveAllUserScripts()so the script is not lost there.Caveat: This is a workaround on the slicer side. Flutter now assumes a Chromium environment on Linux. I only checked the pages below. The better long-term fix is on the web UI side or in WebKit. The checkbox behaviour is also reproducible with plain WebKitGTK 2.54.1 and 2.50.6.
Screenshots/Recordings/Graphs
Not applicable (state of the checkboxes after each click, measured from screenshots, see Tests).
Tests
Environment: Fedora 44 (Nobara), Wayland, NVIDIA RTX 2070 SUPER (620.70), system webkit2gtk4.1 2.54.1, built as AppImage from
main(2.4.2) with this change (plus #1081 and #1205 so that the canvas renders on NVIDIA).Not tested: Windows and macOS (the new function is a no-op there), Flatpak build.